package org.framework.common.api.support.model;

import java.io.Serializable;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonFormat;

@JsonAutoDetect
public class PageModel<ENTITY> implements Serializable {

	private static final long serialVersionUID = 2959768759418849526L;

	private String total;

	@JsonFormat(pattern="yyyy-MM-dd", timezone="GMT+8")
	private List<ENTITY> rows;
	
	public PageModel() {

	}

	public PageModel(long total, List<ENTITY> rows) {
		this.total = String.valueOf(total);
		this.rows = rows;
	}
	
	public List<?> getRows() {
		return rows;
	}
	
	@SuppressWarnings("unchecked")
	public <T> List<T> getRows(Class<T> t) {
		return (List<T>)rows;
	}
	
	public void setRows(List<ENTITY> rows) {
		this.rows = rows;
	}

	public String getTotal() {
		return total;
	}

	public void setTotal(String total) {
		this.total = total;
	}
}
